package top.moxingwang.javawork.proxy.cglib;

import net.sf.cglib.core.DebuggingClassWriter;
import net.sf.cglib.proxy.Enhancer;

public class CglibProxyFactory {
    public static void main(String[] args) {
        // System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "C:\\Users\\m6553\\Desktop");

        // 创建动态代理增强类
        Enhancer enhancer = new Enhancer();
        // 设置类加载器
        enhancer.setClassLoader(AliSmsService.class.getClassLoader());
        // 设置被代理类
        enhancer.setSuperclass(AliSmsService.class);
        // 设置方法拦截器
        enhancer.setCallback(new DebugMethodInterceptor());
        // 创建代理类
        AliSmsService aliSmsService = (AliSmsService) enhancer.create();
        aliSmsService.send("java");


    }
}
